#ifndef TIMERTHREAD_H
#define TIMERTHREAD_H
#include <QMutex>
#include <QThread>
#include <QWaitCondition>
#include <QTime>
#include <QTimer>

namespace Moolink {


class TimerThread: public QThread
{
    Q_OBJECT

public:
    explicit TimerThread(QObject *parent = nullptr);
    ~TimerThread();

    void TimerRun(int waitTimeout);//, const QString &request);
    //void threadQuit();
    // 设置回调函数的函数
    void setCallbackFunc(void(*func) (qint64 UtcSec));
signals:
    void response2(const int devIndex,const QString &devName,const QString &res);
    void error(const QString &s);
    void timeout(const QString &s);



private:
        void(*m_callbackFunc)(qint64 UtcSec);
    void run() override;

//    QQueue<QString> m_request;
    QString m_request;
    int m_waitTimeout = 0;
    int m_rtdInt_s = 30;
    int m_minInt_s = 60;

    QMutex m_mutex;
    QWaitCondition m_cond;
    bool m_quit = false;

public slots:
    void slot_time() ;
signals:
    void response2(int Index);
private:
    QTimer *m_timer;
};

}
#endif // TIMERTHREAD_H
